<?php
class Cart
{
	function __construct(){
		$this->items = array();
	}
	function add_product($product){
		foreach ($this->items as $item){
			if ($item->product->id == $product->id){
				$currentItem = $item;
				break;
			}
		}
		if (isset($currentItem)){
			$currentItem->increment_quantity();
		}else{
			$currentItem = new CartItem($product);
			array_push($this->items,$currentItem);
		}
		return $currentItem;
	}
	function getTotalPrice(){
		foreach ($this->items as $item){
			$sum += $item->getPrice;
		}
		return $sum;
	}
	function getTotalItem(){
		foreach ($this->items as $item){
			$total += $item->quantity;
		}
		return $total;
	}
}